module game{
    export class GameOverView extends BaseEuiView{
        public btn_back:eui.Button;
        public btn_share:eui.Button;
        public btn_showOff:eui.Button;
        public btn_TV:eui.Button;

        public txt_score:eui.Label;
        public txt_time:eui.Label;
        public txt_next:eui.Label;
        
        private time = 10;
        public constructor($m:BaseController,$parent:eui.Group){
            super($m,$parent);
            this.skinName = "resource/skin/GameOver.exml";
        }

        public initUI():void{
            super.initUI();

            const self = this;
            this.btn_back.addEventListener(egret.TouchEvent.TOUCH_TAP,this.backHomeHandler,this);
            this.txt_next.addEventListener(egret.TouchEvent.TOUCH_TAP,this.nextHandler,this);
        }

        public open(...param:any[]):void {
            super.open(...param);

            this.txt_score.text = gameData.curmax +"";

            this.time = 10;
            this.txt_time.text = this.time+"";
            this.txt_next.visible = false;

            App.TimerManager.doTimer(1000,0,this.timeUpdate,this);
        }

        private timeUpdate(){
            this.time --;
            if(this.time == 7){
                this.txt_next.visible = true;
            }
            if(this.time < 0 ){
                this.nextHandler();
                App.TimerManager.remove(this.timeUpdate,this);
                return;
            }
            this.txt_time.text = this.time+"";
        }

        private backHomeHandler(){
            //clearAll
            App.ViewManager.close(ViewConst.Core);
            App.ViewManager.close(ViewConst.GameOver);
            App.ViewManager.open(ViewConst.Home);
        }

        private nextHandler(){
            //跳过
        }


        private gameResult(){
            
        }

        /**复活 */
        private revive(){
            App.ViewManager.close(ViewConst.GameOver);
            App.ViewManager.open(ViewConst.Core)
        }
    }
}